#ifndef funct_H
#define funct_H

#include <string>

struct Function
{
public :
       virtual double value (double x) const = 0;
       virtual ~Function() {}       
};

Function* Build (std::string const & s);

struct SingleVariableFunction : Function
{
	
	~SingleVariableFunction() { delete a_; }

protected:
       Function *a_;
};

struct BinaryFunction : Function
{
	
	~BinaryFunction() { delete a_; delete b_; }

protected:
       Function *a_;
       Function *b_;
};


struct Mult : BinaryFunction
{
public:       
       Mult(Function * a, Function * b);
       double value(double x) const;
};

struct Div : BinaryFunction
{
public:       
       Div(Function * a, Function * b);
       double value(double x) const;
};

struct Plus : BinaryFunction
{
public:       
       Plus(Function * a, Function * b);
       double value(double x) const;
};

struct Minus : BinaryFunction
{
public:       
       Minus(Function * a, Function * b);
       double value(double x) const;
};

struct Power : BinaryFunction
{
public:       
       Power(Function * a, Function * b);
       double value(double x) const;
};

struct Var : Function
{
       //Var();
       double value(double x) const;
       //~Var();
};

struct Sin_ : SingleVariableFunction
{
public:
	   Sin_(Function * a);
       double value(double x) const;
};

struct Cos_ : SingleVariableFunction
{
public:
	   Cos_(Function * a);
       double value(double x) const;
};


struct Const : Function
{
private:
       double c;
public:
       Const(double d);
       double value(double x) const;
       //~Const();
};

#endif